﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using Symbonix.Library.Web.Security.DAL.Repositories;
using System.Collections;
using Symbonix.NorSoNet.Security.DAL.Repositories;
using Symbonix.NorSoNet.Security.BLL.Membership;
using Symbonix.NorSoNet.Framework.BLL;
using Symbonix.Library.DataStructure;

/// <summary>
/// Summary description for wsFriends
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class wsFriends : System.Web.Services.WebService
{

    public wsFriends()
    {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    
    public string[] GetFriendsList(string prefixText, int count)
    {
        int total = 0;

        SystemUser sysUser = new UserFactory().GetUser() as SystemUser;
        ReadWriteCustomCollection<IUser> users=sysUser.FindUser(prefixText);

        //ExtendedUserRepository eur = new ExtendedUserRepository();
        //IList users = eur.FindAllUserByName(prefixText, string.Empty, true, false, 0, 100, out total);
       
        List<string> friendsList = new List<string>();
        for (int i = 0; i < users.Count && i < count; i++)
        {
            IUser friend = (IUser)users[i];
            friendsList.Add(friend.UserName);
        }
        
        return friendsList.ToArray();
    }

}

